<extend name="Public/base"/>

<block name="body">
	<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
	<div class="main-title">
		<h2>编辑</h2>
	</div>
	<div class="tab-wrap">
		<ul class="tab-nav nav">
			<li data-tab="tab1" class="current"><a href="javascript:void(0);">广告信息管理</a></li>
			<!-- <li data-tab="tab2"><a href="javascript:void(0);">高 级</a></li> -->
		</ul>
	
		<div class="data-table table-striped">
			<table width=1000 align="center" cellpadding="10" cellspacing="0" border="1" class="table-hover" >
				
			</table>

		<table>
	    <thead>
	        <tr>
				<th>ID</th>
				<th>图片</th>
				<!-- <th>修改图片</th> -->
				<th>状态</th>
				<th>创建时间</th>
				<th>公司名称</th>
				<th>链接地址</th>
				<th>操作</th>
			</tr>
	    </thead>
		    <tbody>
				<tr>
				<form action="{:U('Gname/editAc')}" method="post" >
		            <volist name="arr" id="v">
						<tr class="show_td">
							<td>{$v.id}</td>
							<td><img src="__ROOT__{$v.path}" alt="" width=80 height=80 ></td>
								<input type="hidden" name='id' value="{$v.id}">
							<!-- <td>
								<div class="controls">
									<label class="item-label"></label>
									<input type="file" id="upload_picture">
									<input type="hidden" name="icon" id="icon" value="{$info['icon']|default=''}"/>
									<div class="upload-img-box">
									<notempty name="info['icon']">
										<div class="upload-pre-item">
										<img src="__ROOT__{$info.icon|get_cover='path'}"/></div>
									</notempty>
									</div>
								</div>
							</td> -->
							<td>
								<if condition="($v['status'] eq 1) ">
									<a href="{:U('Gname/dis',array('id'=>$v['id']))}" >显示</a>
								<else /> 
									<a href="{:U('Gname/nodis',array('id'=>$v['id']))}" >不显示</a>
								</if>
							</td>

							<td><?php echo date('Y-m-d',$v['create_time'])?></td>
							<td><input type="text" name="kname" value="{$v.kname}" style="background-color: #f2f2f2;"></td>
							<td> <input type="text" name="a_lian" value="{$v.a_lian}" style="background-color: #f2f2f2;" width=236></td>
							<td>
								<input type="submit" value="确认编辑">
							</td>
						</tr>
					</volist>

					<div>
						<script type="text/javascript">
						//上传图片
					    /* 初始化上传插件 */
						$("#upload_picture").uploadify({
					        "height"          : 30,
					        "swf"             : "__STATIC__/uploadify/uploadify.swf",
					        "fileObjName"     : "download",
					        "buttonText"      : "上传图片",
					        "uploader"        : "{:U('Gname/uploadPic',array('id'=>$v['id']))}",
					        "width"           : 120,
					        'removeTimeout'	  : 1,
					        'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
					        "onUploadSuccess" : uploadPicture,
					        'onFallback' : function() {
					            alert('未检测到兼容版本的Flash.');
					        }
					    });



						function uploadPicture(file, data){
					    	var data = $.parseJSON(data);
					    	var src = '';
					        if(data.status){
					        	$("#icon").val(data.id);
					        	src = data.url || '__ROOT__' + data.path;
					        	$("#icon").parent().find('.upload-img-box').html(
					        		'<div class="upload-pre-item"><img src="' + src + '"/></div>'
					        	);
					        } else {
					        	updateAlert(data.info);
					        	setTimeout(function(){
					                $('#top-alert').find('button').click();
					                $(that).removeClass('disabled').prop('disabled',false);
					            },1500);
					        }
					    }
						</script>
					</div>
				</form>	
				</tr>			
			</tbody>
	    </table>
		</div>
	



        </div>
        
    </div>
    <!-- /内容区 -->
    <script type="text/javascript">
    (function(){
        var ThinkPHP = window.Think = {
            "ROOT"   : "/onethink", //当前网站地址
            "APP"    : "/onethink/index.php?s=", //当前项目地址
            "PUBLIC" : "/onethink/Public", //项目公共目录地址
            "DEEP"   : "/", //PATHINFO分割符
            "MODEL"  : ["3", "", "html"],
            "VAR"    : ["m", "c", "a"]
        }
    })();
    </script>
    <script type="text/javascript" src="/onethink/Public/static/think.js"></script>
    <script type="text/javascript" src="/onethink/Public/Admin/js/common.js"></script>
    <script type="text/javascript">
	    function del(obj){
	    	// console.log(obj);
	    	var k_id = $(obj).attr("k_id");
	    	// console.log(k_id);
	    	var url = $(obj).attr('date_url');
	    	// alert($(obj).attr("date_url")); 
	    	console.log($(obj).parent().parent().parent());

	    	$.ajax({
	    		type:'get',
	    		url:url,
	    		data:'k_id='+k_id,
	    		dataType:'json',
	    		success:function(date){
	    			alert(date.msg);
	    			document.location.reload();
	    		}
	    	})
	    	return false;
	    }


        +function(){
            var $window = $(window), $subnav = $("#subnav"), url;
            $window.resize(function(){
                $("#main").css("min-height", $window.height() - 130);
            }).resize();

            /* 左边菜单高亮 */
            url = window.location.pathname + window.location.search;
            url = url.replace(/(\/(p)\/\d+)|(&p=\d+)|(\/(id)\/\d+)|(&id=\d+)|(\/(group)\/\d+)|(&group=\d+)/, "");
            $subnav.find("a[href='" + url + "']").parent().addClass("current");

            /* 左边菜单显示收起 */
            $("#subnav").on("click", "h3", function(){
                var $this = $(this);
                $this.find(".icon").toggleClass("icon-fold");
                $this.next().slideToggle("fast").siblings(".side-sub-menu:visible").
                      prev("h3").find("i").addClass("icon-fold").end().end().hide();
            });

            $("#subnav h3 a").click(function(e){e.stopPropagation()});

            /* 头部管理员菜单 */
            $(".user-bar").mouseenter(function(){
                var userMenu = $(this).children(".user-menu ");
                userMenu.removeClass("hidden");
                clearTimeout(userMenu.data("timeout"));
            }).mouseleave(function(){
                var userMenu = $(this).children(".user-menu");
                userMenu.data("timeout") && clearTimeout(userMenu.data("timeout"));
                userMenu.data("timeout", setTimeout(function(){userMenu.addClass("hidden")}, 100));
            });

	        /* 表单获取焦点变色 */
	        $("form").on("focus", "input", function(){
		        $(this).addClass('focus');
	        }).on("blur","input",function(){
				        $(this).removeClass('focus');
			        });
		    $("form").on("focus", "textarea", function(){
			    $(this).closest('label').addClass('focus');
		    }).on("blur","textarea",function(){
			    $(this).closest('label').removeClass('focus');
		    });

            // 导航栏超出窗口高度后的模拟滚动条
            var sHeight = $(".sidebar").height();
            var subHeight  = $(".subnav").height();
            var diff = subHeight - sHeight; //250
            var sub = $(".subnav");
            if(diff > 0){
                $(window).mousewheel(function(event, delta){
                    if(delta>0){
                        if(parseInt(sub.css('marginTop'))>-10){
                            sub.css('marginTop','0px');
                        }else{
                            sub.css('marginTop','+='+10);
                        }
                    }else{
                        if(parseInt(sub.css('marginTop'))<'-'+(diff-10)){
                            sub.css('marginTop','-'+(diff-10));
                        }else{
                            sub.css('marginTop','-='+10);
                        }
                    }
                });
            }
        }();
    </script>
    
	<script src="/onethink/Public/static/thinkbox/jquery.thinkbox.js"></script>

	<script type="text/javascript">
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});
	//回车搜索
	$(".search-input").keyup(function(e){
		if(e.keyCode === 13){
			$("#search").click();
			return false;
		}
	});
    //导航高亮
    highlight_subnav('/onethink/index.php?s=/Admin/User/index.html');
	</script>

			
</block>


<block name="script">
	<script type="text/javascript">

		// function alt(){
		// 	if(confirm('确认提交吗？'))
		// }


		<present name="info.id">
		Think.setValue("allow_publish", {$info.allow_publish|default=1});
		Think.setValue("check", {$info.check|default=0});
		Think.setValue("model[]", {$info.model|json_encode} || [1]);
		Think.setValue("type[]", {$info.type|json_encode} || [2]);
		Think.setValue("display", {$info.display|default=1});
		Think.setValue("reply", {$info.reply|default=0});
		Think.setValue("reply_model[]", {$info.reply_model|json_encode} || [1]);
		</present>

		$(function(){
			showTab();
			$("input[name=reply]").change(function(){
				var $reply = $(".form-item.reply");
				parseInt(this.value) ? $reply.show() : $reply.hide();
			}).filter(":checked").change();
		});
		//导航高亮
		highlight_subnav('{:U('Category/index')}');
	</script>
</block>
